#!/bin/bash
# =============================================================
result=$(docker ps | grep "magical-machine")
if [[ "$result" != "" ]]
then
echo "stop magical-machine"
docker stop magical-machine
fi

result1=$(docker ps -a | grep "magical-machine")
if [[ "$result1" != "" ]]
then
echo "rm magical-machine"
docker rm magical-machine
fi

result2=$(docker images | grep "magical-machine")
if [[ "$result2" != "" ]]
then
echo "rm image"
docker rmi mo/magical-machine:1.0-SNAPSHOT
fi


# =============================================================
echo "start docker container ..."

id=$(docker run -d --name magical-machine --network xxl-job-admin_default mo/magical-machine:1.0-SNAPSHOT)
echo "container id: $id"